﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Tetris
{
    [Serializable]
    public class Line : Shape
    {
        //global number of state for the shape
        public static int NbState = 2;

        /// <summary>
        /// basic constructor used when we deserialize
        /// </summary>
        public Line() : base()
        {
            points.Clear();
        }

        /// <summary>
        /// Basic constructor
        /// </summary>
        public Line(bool test) : base()
        {
            points[0].X=4;
            points[0].Y=0;
            points[1].X=4;
            points[1].Y=1;
            points[2].X=4;
            points[2].Y=2;
            points[3].X=4;
            points[3].Y=3;
            state = 1;
        }

        /// <summary>
        /// Organized how the leftL will rotate according to its current state
        /// </summary>
        /// <param name="sens">Shape.COUNTCLOCKWISE or Shape.CLOCKWISE</param>
        public override void rotate(int sens)
        {
            if (state == 1)
            {
                points[0].X=points[0].X - 1;
                points[0].Y=points[0].Y + 1;

                points[2].X=points[2].X + 1;
                points[2].Y=points[2].Y - 1;

                points[3].X=points[3].X + 2;
                points[3].Y=points[3].Y - 2;
                state = 2;
            }else if (state == 2)
            {
                points[0].X=points[0].X + 1;
                points[0].Y=points[0].Y - 1;

                points[2].X=points[2].X - 1;
                points[2].Y=points[2].Y + 1;

                points[3].X=points[3].X - 2;
                points[3].Y=points[3].Y + 2;
                state = 1;
            }
        }
    }
}
